Package PayPalAPI.api.ebay

Source Code of PayPalAPI.api.ebay.DoAuthorizationResponseType

/**
* DoAuthorizationResponseType.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.2.1 Jun 14, 2005 (09:15:57 EDT) WSDL2Java emitter.
*/

package PayPalAPI.api.ebay;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import CoreComponentTypes.apis.ebay.BasicAmountType;
import eBLBaseComponents.apis.ebay.AckCodeType;
import eBLBaseComponents.apis.ebay.CurrencyCodeType;
import eBLBaseComponents.apis.ebay.SeverityCodeType;

public class DoAuthorizationResponseType  extends eBLBaseComponents.apis.ebay.AbstractResponseType  implements java.io.Serializable {
    /**
   *
   */
  private static final long serialVersionUID = 8002694061189660565L;
  private static final Log LOG = LogFactory.getLog(DoAuthorizationResponseType.class.getName());
  /** An authorization identification number.
*                
*                    
* Character length and limits: 19 single-byte characters */
    private java.lang.String transactionID;
    /** The amount and currency you specified in the request. */
    private CoreComponentTypes.apis.ebay.BasicAmountType amount;

    public DoAuthorizationResponseType() {
    }

    public DoAuthorizationResponseType(
           java.lang.String transactionID,
           CoreComponentTypes.apis.ebay.BasicAmountType amount) {
           this.transactionID = transactionID;
           this.amount = amount;
    }
   
    public DoAuthorizationResponseType(InputStream _is) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(_is));
      String currentLine = null;
     
      Map<String, String> delayedFields = new HashMap<String, String>();
     
    try {
      while ((currentLine = reader.readLine()) != null) {
        String[] pairs = StringUtils.split(currentLine, "&");
        if (LOG.isDebugEnabled()) {
          LOG.debug("Read line [" + currentLine + "], split into " + pairs.length + " pairs.");
        }
        for (int i = 0; i < pairs.length; i++) {
          String[] nvp = StringUtils.split(pairs[i], "=");
          String name = nvp[0];
          String value = null;
          if (nvp.length == 2) {
            value = URLDecoder.decode(nvp[1], "UTF-8");
          }
          if (LOG.isDebugEnabled()) {
            LOG.debug("Read pair [" + name + "]/[" + value + "]");
          }
          if (isCommonField(name)) {
            processCommonField(name, value);
          }
          // Process fields
          else if (name.equals(FIELD_TRANSACTIONID)) {
            setTransactionID(value);
          }
          else if (name.equals(FIELD_AMT)) {
            delayedFields.put(FIELD_AMT, value);
          }
          else if (name.equals(FIELD_CURRENCYCODE)) {
            delayedFields.put(FIELD_CURRENCYCODE, value);
          }
          else if (LOG.isErrorEnabled()) {
            LOG.error("Unknown field returned in DoAuthorization: [" + name + "]");
          }
        }
       
        // Process the delayed fields
        if (delayedFields.containsKey(FIELD_AMT)) {
          BasicAmountType amount = new BasicAmountType((String) delayedFields.get(FIELD_AMT));
          if (delayedFields.containsKey(FIELD_CURRENCYCODE)) {
            amount.setCurrencyID(CurrencyCodeType.fromString((String) delayedFields.get(FIELD_CURRENCYCODE)));
          }
          setAmount(amount);
        }
      }
    } catch (Exception e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Exception caught processing response: " + e.getLocalizedMessage(), e);
      }
      setAck(AckCodeType.Failure);
      addSeverityCode("L_SEVERITYCODE0", SeverityCodeType.Error.toString());
      addErrorCode("L_ERRORCODE0", "JC1000");
      addLongMessage("L_LONGMESSAGE0", "Error processing GetTransactionDetails API call");
      addShortMessage("L_SHORTMESSAGE0", "Error processing request");
    }     
    }


    /**
     * Gets the transactionID value for this DoAuthorizationResponseType.
     *
     * @return transactionID An authorization identification number.
*                
*                    
* Character length and limits: 19 single-byte characters
     */
    public java.lang.String getTransactionID() {
        return transactionID;
    }


    /**
     * Sets the transactionID value for this DoAuthorizationResponseType.
     *
     * @param transactionID An authorization identification number.
*                
*                    
* Character length and limits: 19 single-byte characters
     */
    public void setTransactionID(java.lang.String transactionID) {
        this.transactionID = transactionID;
    }


    /**
     * Gets the amount value for this DoAuthorizationResponseType.
     *
     * @return amount The amount and currency you specified in the request.
     */
    public CoreComponentTypes.apis.ebay.BasicAmountType getAmount() {
        return amount;
    }


    /**
     * Sets the amount value for this DoAuthorizationResponseType.
     *
     * @param amount The amount and currency you specified in the request.
     */
    public void setAmount(CoreComponentTypes.apis.ebay.BasicAmountType amount) {
        this.amount = amount;
    }

    private java.lang.Object __equalsCalc = null;
    public synchronized boolean equals(java.lang.Object obj) {
        if (!(obj instanceof DoAuthorizationResponseType)) return false;
        DoAuthorizationResponseType other = (DoAuthorizationResponseType) obj;
        if (obj == null) return false;
        if (this == obj) return true;
        if (__equalsCalc != null) {
            return (__equalsCalc == obj);
        }
        __equalsCalc = obj;
        boolean _equals;
        _equals = super.equals(obj) &&
            ((this.transactionID==null && other.getTransactionID()==null) ||
             (this.transactionID!=null &&
              this.transactionID.equals(other.getTransactionID()))) &&
            ((this.amount==null && other.getAmount()==null) ||
             (this.amount!=null &&
              this.amount.equals(other.getAmount())));
        __equalsCalc = null;
        return _equals;
    }

    private boolean __hashCodeCalc = false;
    public synchronized int hashCode() {
        if (__hashCodeCalc) {
            return 0;
        }
        __hashCodeCalc = true;
        int _hashCode = super.hashCode();
        if (getTransactionID() != null) {
            _hashCode += getTransactionID().hashCode();
        }
        if (getAmount() != null) {
            _hashCode += getAmount().hashCode();
        }
        __hashCodeCalc = false;
        return _hashCode;
    }

}
TOP

Related Classes of PayPalAPI.api.ebay.DoAuthorizationResponseType

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.